<template>
	<view>
		<view>平均分: {{ statistics.average.toFixed(2) }}</view>
		<view>最高分: {{ statistics.max }}</view>
		<view>最低分: {{ statistics.min }}</view>
		<!-- 其他统计信息 -->
	</view>
</template>

<script>
	// 假设这是你从后端获取到的成绩数据  
	// let scores = [  
	//   { name: 'Alice', score: 85 },  
	//   { name: 'Bob', score: 92 },  
	//   { name: 'Charlie', score: 78 },  
	//   // ... 其他学生数据  
	// ];  

	// 在你的 Vue 组件中  
	export default {
		data() {
			return {
				scores: [{
						name: 'Alice',
						score: 85
					},
					{
						name: 'Bob',
						score: 92
					},
					{
						name: 'Charlie',
						score: 78
					},
				], // 初始为空，实际使用时应从后端获取  
				statistics: {
					average: 0,
					max: 100,
					min: 60,
				},
			};
		},
		created() {
			// 假设这里你已经通过某种方式（如调用API）获取了scores数据  
			// this.scores = scores; // 示例数据  
			this.calculateStatistics();
		},
		methods: {
			calculateStatistics() {
				if (this.scores.length === 0) return;

				let sum = 0;
				this.scores.forEach(score => {
					sum += score.score;
					if (score.score > this.statistics.max) {
						this.statistics.max = score.score;
					}
					if (score.score < this.statistics.min) {
						this.statistics.min = score.score;
					}
				});

				this.statistics.average = sum / this.scores.length;
			},
		},
	};
</script>

<style>

</style>